% The function returns Population, the initial population for the genetic
% algorithm.
function Population = creationFnc(GenomeLength, FitnessFcn, options)
% Genomelength — Number of independent variables for the fitness function
% FitnessFcn   — Fitness function
% options      — Options structure

Population = zeros(options.PopulationSize, GenomeLength);
for i = 1 : options.PopulationSize
    Population(i, 1:GenomeLength) = 1:GenomeLength;
end

for i = 1 : options.PopulationSize
    for j = 2 : GenomeLength*2
        m = randi([2 GenomeLength]);
        n = randi([2 GenomeLength]);
        
        tmp              = Population(i, n);
        Population(i, n) = Population(i, m);
        Population(i, m) = tmp;
    end
end

end
